use t::MYTEST 'no_plan';

# PERL5LIB=.:$PERL5LIB prove t/core/log.t -v

# repeat_each。它其实是一个 perl 函数，默认情况下是 repeat_each(1)，表示测试案例只运行一次
repeat_each(1);
no_long_string();
no_root_location();

run_tests();


__DATA__
=== TEST 1: add white list ip
--- config
    location /t {
        content_by_lua_block {
            local whitefilter = require("plugins.whitefilter")
            local red = whitefilter.get_red()
            red:set("1.1.1.1","")
            red:set("1.1.1.2","")
            ngx.say("done")
        }
    }
--- request
GET /t
--- error_code: 200

=== TEST 2: config white ip
--- config
    location /t {
        content_by_lua_block {

            ngx.say("done")
        }
    }
--- request
GET /t
--- more_headers
x-connecting-ip: 1.1.1.9
--- error_code: 200

=== TEST 3: config api_allow_ip
--- config
    location /t {
        content_by_lua_block {

            ngx.say("done")
        }
    }
--- request
GET /t
--- error_code: 200

=== TEST 4: white ip 1
--- config
    location /t {
        content_by_lua_block {
            ngx.say("done")
        }
    }
--- request
GET /t
--- more_headers
x-connecting-ip: 1.1.1.1
--- error_code: 200

=== TEST 5: white ip 2
--- config
    location /t {
        content_by_lua_block {
            ngx.say("done")
        }
    }
--- request
GET /t
--- more_headers
x-connecting-ip: 1.1.1.2
--- error_code: 200

=== TEST 6: black ip
--- config
    location /t {
        content_by_lua_block {

            ngx.say("done")
        }
    }
--- request
GET /t
--- more_headers
x-connecting-ip: 1.1.1.12
--- error_code: 403
